﻿//
// Copyright (c) 2024 BPer
//

#ifndef BPERDECODER_SRC_BPerDecoderOpenh264_H_
#define BPERDECODER_SRC_BPerDecoderOpenh264_H_
#include <bperdecoder/BPerVideoDecoder.h>
#include <bperutil/sys/BPerLoadLib.h>
#include <bperutil/BPerType.h>
#include <wels/codec_api.h>
class BPerDecoderOpenh264: public BPerVideoDecoder {
public:
	BPerDecoderOpenh264();
	virtual ~BPerDecoderOpenh264();
	void parseRtmpHeader(uint8_t *p, int32_t pLen, int32_t *pwid, int32_t *phei, int32_t *pfps);
	void init();
	int32_t decode(BPerFrame* videoFrame,BPerYuvType yuvtype,BPerDecoderCallback* pcallback);

private:
	uint8_t* m_buffer;
	int32_t m_bufLen;
	int32_t m_width,m_height;
	int32_t m_uPos,m_vPos;
	SBufferInfo m_dstBufInfo;
private:
	ISVCDecoder *m_svcDecoder;
	void getH264RtmpHeader(uint8_t *buf, uint8_t *src, int32_t *hLen);
	void writeData(BPerFrame* videoFrame,uint8_t** pData,BPerDecoderCallback* pcallback);

};

#endif /* BPERDECODER_SRC_BPERH264DECODERSOFT_H_ */
